// base
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
// less
import './index.less'
import { showModal } from '../../../crossplatform/apiservice/toast'

class ShowAddress extends Component {
  componentWillMount () {
    // onLoad
  }

  componentDidMount () {
    // onready
  }

  componentWillUnmount () {
    // onUnload
  }

  componentWillReceiveProps (nextprops) {}

  delay (time = 0) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve()
      }, time)
    })
  }

  onDelete = idx => {
    showModal({
      title: '提示',
      content: '确认删除该地标吗？'
    }).then(({ confirm }) => {
      if (confirm) {
        const { dataSource } = this.props
        let newData = []
        dataSource.forEach((data, index) => {
          if (idx != index) {
            newData.push(data)
          }
        })
        this.props.onUpdateState({
          workPlace: newData
        })
      }
    })
  }

  render () {
    const { dataSource, pagetype } = this.props
    return (
      <View className="ShowAddress_id56241">
        {dataSource && dataSource.length
          ? dataSource.map((data, index) => {
            return data.choosed ? (
              <View className="single">
                <Image
                  src="https://imagesize.hrwork.com/sp/files/58dde1f8-d117-4751-b800-cc996e6f2830.png"
                  className="image-ls"
                />
                <View className="text-in">{data.addressSimple || data.address} {data.roomInfo || ''}</View>
              </View>
            ) : (
              ''
            )
          })
          : pagetype != 'fulltime'
            ? // <View className="single">
            // 	<Image src="https://imagesize.hrwork.com/sp/files/58dde1f8-d117-4751-b800-cc996e6f2830.png"
            // 	       className="image-ls"/>
            // 	<View className="text-in">
            // 		不限地点
            // 	</View>
            // </View>
            null
            : null}
      </View>
    )
  }
}

export default ShowAddress
